package day05.am;

public class Demo02 {
    public static void main(String[] args) {
        //1.算术运算符
        int a = 5;
        int b = 2;
        int sum = a+b;//-  *
        System.out.println(sum);
        int c = a/b;//除号两边都是整数，就是整除
        System.out.println(c);
        System.out.println(a%b);
        System.out.println(5%6);
        //2.赋值运算符
        a = 5;
        System.out.println("a="+a);//a=5
        a += 6;//a = a+6;
        System.out.println("a="+a);//a=11
        a -= 3;//a=a-3
        System.out.println("a="+a);//a=8
        //3.关系运算符
        a=8;b=9;
        if(a>b){
            System.out.println(a+"大");
        }
        if(a<b){
            System.out.println(b+"大");
        }
        if(a==b){
            System.out.println(a+"和"+b+"相等");
        }
        //4.逻辑运算符
        //假设华美整形医院只允许,年龄大于20的女性进入
        int age=21; boolean sex = false;//true表示男
        if(!sex && age>20){
            System.out.println("欢迎光临");
        }else{
            System.out.println("您不符合进入条件");
        }
        //5.自增自减运算符
        //++ --  int a = 5; a++ ++a  a-- --a
        a = 5;
        c = a++;//后++,先运算，后自己加1 c=a,a=a+1
        System.out.println("c="+c+",a="+a);
        c = ++a;//前++,先自己加1，再运算 a=a+1;c=a
        System.out.println("a="+a+",c="+c);//a=7,c=7
        //6.三目运算符: 表达式?表达式2:表达式3;
        sex = false;//true表示男
//        System.out.println(sex==true?'男':'女');
        System.out.println(sex?'男':'女');
        a = 6;
        System.out.println(a>6?6.6:6);
        //7.字符串连接符: +
        //字符串和任何类型连接后都是字符串，+号两边都是数字,才是相加
        System.out.println(123+34);//157
        System.out.println(1+2+3+"abc"+4+5+6);//6abc456
        System.out.println(1+2+3+"abc"+(4+5+6));//6abc15
    }
}
